#Imports
import wx
import os
import cardbase_internals as cb

#Constants


#GUI Codes
ACT_ISSUE_SINGLE = 1
ACT_ISSUE_SPREADSHEET = 
ACT_RETURN = 
CARD_ADD_SINGLE = 
CARD_ADD_SPREADSHEET = 
CARD_DELETE_SINGLE = 
CARD_DELETE_SPREADSHEET =
REP_LOOKUP = 
REP_OVERDUE = 
REP_DELETED =  
SETTINGS_PREFS = 
SETTINGS_QUIT = 
HELP_DOCS = 
HELP_REPORT_BUG = 
HELP_WEBSITE = 
HELP_ABOUT = 

#Code
class Main():
    def __init__(self, user, parent, id, title):
        wx.Frame.__init__(self, parent, id, title, size=(300, 150))
        #self.SetIcon(wx.Icon(ICON_PATH, wx.BITMAP_TYPE_PNG))
        self.user = user
        
        menubar = wx.MenuBar()
        
        actions = wx.Menu()
        actions_issue = wx.Menu()
        card_management = wx.Menu()
        card_management_add = wx.Menu()
        card_management_delete = wx.Menu() 
        key_management = wx.Menu()
        reporting = wx.Menu()   
        settings = wx.Menu()
        help = wx.Menu()
        
        act_issue_single = wx.MenuItem(actions, ACT_ISSUE_SINGLE, '&Single Card')
        act_issue_spreadsheet = wx.MenuItem(actions, ACT_ISSUE_SPREADSHEET, '&From Spreadsheet...')
        act_return = wx.MenuItem(actions, ACT_RETURN, '&Return')
        card_add_single = wx.MenuItem(card_management_add, CARD_ADD_SINGLE, '&Single Card')
        card_add_spreadsheet = wx.MenuItem(card_management_add, CARD_ADD_SPREADSHEET, '&From Spreadsheet...')
        card_delete_single = wx.MenuItem(card_management_delete, CARD_DELETE_SINGLE, '&Single Card')
        card_delete_spreadsheet = wx.MenuItem(card_management_delete, CARD_DELETE_SPREADSHEET, '&From Spreadsheet...')
        rep_lookup = wx.MenuItem(reporting, REP_LOOKUP, '&Lookup Card')
        rep_overdue = wx.MenuItem(reporting, REP_OVERDUE, '&List Overdue Cards')
        rep_deleted = wx.MenuItem(reporting, REP_DELETED, '&List Deleted Cards')
        settings_quit = wx.MenuItem(settings, SETTINGS_QUIT, '&Quit')
        help_docs = wxMenuItem(help, HELP_DOCS, '&Documentation')
        help_report_bug = wxMenuItem(help, HELP_REPORT_BUG, '&Report a Bug')
        help_website = wxMenuItem(help, HELP_WEBSITE, '&Visit Website')
        help_about = wx.MenuItem(help, HELP_ABOUT, '&About')

        
        #Populate menus USE COMBINATION FOR LOOPS
        actions_menu = [act_return]
        for item in actions_issue_menu:
            actions.AppendItem(item) 
        
        actions_issue_menu = [act_issue_single, act_issue_spreadsheet]
        for item in actions_issue_menu:
            actions_issue.AppendItem(item)
            
        card_management_add_menu = [card_add_single, card_add_spreadsheet]
        for item in card_management_add_menu:
            card_management_add.AppendItem(item)
            
        card_management_delete_menu = [card_delete_single, card_delete_spreadsheet]
        for item in card_management_delete_menu:
            card_management_delete.AppendItem(item)
        
        rep_menu = [rep_lookup, rep_overdue, rep_deleted]
        for item in rep_menu:
            reporting.AppendItem(item)
        
        settings_menu = [settings_quit]
        for item in settings_menu:
            settings.AppendItem(item)

        help_menu = [help_docs, help_report_bug, help_website, help_about]
        for item in help_menu:
            help.AppendItem(item)
    
        actions.AppendMenu(-1, '&Issue Card(s)', actions_issue)
        card_management.AppendMenu(-1, '&Add Card(s)', card_management_add)
        card_management.AppendMenu(-1, '&Delete Card(s)', card_management_delete)
    
        #Add menus to menubar USE DICT AND LOOP
        menubar.Append(actions, '&Actions')
        menubar.Append(card_management, '&Card Management')
        menubar.Append(reporting, '&Reporting')
        menubar.Append(settigs, '&Settings')
        menubar.Append(help, '&Help')
        self.SetMenuBar(menubar)
        
        #Bind menu events
        self.Bind(wx.EVT_MENU, self.on_man_users, id=ID_MAN_USERS)
        self.Bind(wx.EVT_MENU, self.on_man_rooms, id=ID_MAN_ROOMS)
        self.Bind(wx.EVT_MENU, self.on_man_keys, id=ID_MAN_KEYS)
        self.Bind(wx.EVT_MENU, self.on_man_cards, id=ID_MAN_CARDS)
        self.Bind(wx.EVT_MENU, self.on_man_licences, id=ID_MAN_LICENCES)
        self.Bind(wx.EVT_MENU, self.on_stu_add, id=ID_STU_ADD)
        self.Bind(wx.EVT_MENU, self.on_stu_custom_group, id=ID_STU_CUSTOM_GROUP)
        self.Bind(wx.EVT_MENU, self.on_rooms_occupant, id=ID_ROOMS_OCCUPANT)
        self.Bind(wx.EVT_MENU, self.on_rooms_custom_group, 
        id=ID_ROOMS_CUSTOM_GROUP)
        self.Bind(wx.EVT_MENU, self.on_keys_issue, id=ID_KEYS_ISSUE)
        self.Bind(wx.EVT_MENU, self.on_keys_smart_lookup,
        id=ID_KEYS_SMART_LOOKUP)
        self.Bind(wx.EVT_MENU, self.on_keys_outstanding, id=ID_KEYS_OUTSTANDING)
        self.Bind(wx.EVT_MENU, self.on_keys_orders, id=ID_KEYS_ORDERS)
        self.Bind(wx.EVT_MENU, self.on_cards_issue, id=ID_CARDS_ISSUE)
        self.Bind(wx.EVT_MENU, self.on_cards_smart_lookup,
        id=ID_CARDS_SMART_LOOKUP)
        self.Bind(wx.EVT_MENU, self.on_cards_outstanding,
        id=ID_CARDS_OUTSTANDING)
        self.Bind(wx.EVT_MENU, self.on_maint_report_job, id=ID_MAINT_REPORT_JOB)
        self.Bind(wx.EVT_MENU, self.on_maint_smart_lookup,
        id=ID_MAINT_SMART_LOOKUP)
        self.Bind(wx.EVT_MENU, self.on_rep_occupancy, id=ID_REP_OCCUPANCY)
        self.Bind(wx.EVT_MENU, self.on_rep_arr_expected, id=ID_REP_ARR_EXPECTED)
        self.Bind(wx.EVT_MENU, self.on_rep_arr_actual, id=ID_REP_ARR_ACTUAL)
        self.Bind(wx.EVT_MENU, self.on_rep_arr_non, id=ID_REP_ARR_NON)
        self.Bind(wx.EVT_MENU, self.on_rep_dep_expected, id=ID_REP_ARR_EXPECTED)
        self.Bind(wx.EVT_MENU, self.on_rep_dep_actual, id=ID_REP_ARR_ACTUAL)
        self.Bind(wx.EVT_MENU, self.on_rep_dep_non, id=ID_REP_DEP_NON)
        self.Bind(wx.EVT_MENU, self.on_tools_quit, id=ID_TOOLS_QUIT)
        self.Bind(wx.EVT_MENU, self.on_help_about, id=ID_HELP_ABOUT)
        
        #Bind general events
        self.Bind(wx.EVT_CLOSE, self.on_close)
        
        #Create panels
       
        #Display parameters
        self.CreateStatusBar()
        self.Centre()
        self.Show(True)
          
    #Define menu events
    def on_settings_quit(self, event):
        self.Close()
        
    def on_help_about(self, event):
        dlg = wx.MessageDialog(self, "CardBase Key and Card Management System. \
                               \nCopyright John Harris 2011.\n\nYou are logged in \
                               as %s." % self.user, 
                               "CardBase", wx.OK | wx.ICON_INFORMATION)
        dlg.ShowModal()
        dlg.Destroy()
    
    #Define general event handlers
    def on_close(self, event):
        dial = wx.MessageDialog(None, 'Are you sure you want to quit?', 'Question',
            wx.YES_NO | wx.NO_DEFAULT | wx.ICON_QUESTION)
        ret = dial.ShowModal()
        if ret == wx.ID_YES:
            self.Destroy()
        else:
            event.Veto()
    
    
app = wx.App(0)
Main(None, -1, 'CardBase Temporary Pass Management System')
app.MainLoop()